empty
cd ..\lib
Requires Quest
cd ..\tests

Only Forth Definitions

\ Tileset/Tilemap
s" test_sheet.png" Graphic: gfx
16 16 gfx Tileset: ts
ts 256 256 Tilemap: map
600.0 400.0 map << w 2v!
origin 0 0 map tile[] 256 256 * 2* move
0 0 map tile[] mem

: tilemap-test
   >seki
   100 0 do
     cls     1.0 1.0 map +scroll
      map show
      end-frame
   loop  ;

\ Rendering
Motif: obj1
Motif: obj2
Motif: obj3
Motif: obj4
Motif: container

obj1 << :noname  show:[ pos 2v@ at  100 100 color @ ovalf ;] ; execute  320 rnd 480 rnd 0 pos 3v!  red color !
obj2 << :noname  show:[ pos 2v@ at  80 120 color @ rectf ;] ; execute  320 rnd 480 rnd 0 pos 3v!  blue color !  128 !alpha
obj3 << :noname  show:[ pos 2v@ at  200 200 color @ line ;] ; execute 640 rnd 480 rnd 0 pos 3v!  green color !
obj4 << :noname  show:[ pos 2v@ at  50 90 color @ ovalf ;] ; execute  320 rnd 480 rnd 0 pos 3v!  orange color !  64 !alpha

container << 2dcamera
obj1 container add
obj2 container add
obj3 container add
obj4 container add

: render-test
   25 0 do cls container render end-frame loop ;

0 value ii

cell blk property index

: dot
   ii index !
   1 +to ii
   me container add
   show:[
      push-modelview
      glTranslatef( 0e 0e z @ s>f index @ s>f 1024e f/ f+ )
      pos 2v@ at  50 50 color @ ovalf
      pop-modelview
   ;]
   -1 rnd 255 a color !

   1024 rnd z !
   screen-w rnd screen-h rnd pos 2v! ;

\ Tween
0 value t

create tweens
   sine-ease ,
   linear-ease  ,
   exponential-ease ,
   quadratic-ease ,
   cubic-ease ,
   quartic-ease ,
   quintic-ease ,
   circular-ease ,
   back-ease ,

create in/outs
   in ,
   out ,
   in-out ,

Motif: tweener

: sequence
   0 to t
   me main new-task act:[ <<
      9 3 * 0 do
         \ t 3 / .
         100 x !
         100 y !
         t 3 / cells tweens + @
         t 3 mod cells in/outs + @
         x 500 60 tween
         10 pauses
         1 +to t
      loop
      end ;] ;

: tween-test
   tweener << dot  sequence  50 50 pos 2v!  0 z !  white color ! >>
   begin
      pause
      cls container render end-frame
   t 9 3 * >= until ;

\ Many dynamic objects

: animate
   me main new-task act:[ <<
     exponential-ease out x screen-w rnd 100 tween
     linear-ease in color 3 + 0 200 rnd ctween
     me remove me dispose end ;]
   me main new-task act:[
     << exponential-ease out y screen-h rnd 100 tween end ;]
   ;


: object-test
   400 gl-benchmark:[
      generate << dot animate >>
      pause
      cls container render \ end-frame
   ;]
   dup cr ." Mean microseconds: " .
   dup cr ." Mean FPS: " fps ..
       cr ." Mean frame time: " .drawtime  ;


640 480 false s" Development" init-display
>ide

init-all

tilemap-test
render-test
object-test
tween-test
